package com.anosine.gpsl.android.impl;

import com.anosine.gpsl.android.AppConstants;
import com.anosine.gpsl.android.WebConstants;
import com.anosine.gpsl.android.dao.FeedBackDao;
import com.anosine.gpsl.android.dao.RegAgreementDao;
import com.anosine.gpsl.android.entity.Login;
import com.anosine.gpsl.android.entity.ModifyPwdInfo;
import com.anosine.gpsl.android.presenter.BasePresenterActivity.OnLoadListener;
import com.anosine.gpsl.android.util.HttpRequestListener;
import com.anosine.gpsl.android.util.SendHttpUtils;
import com.anosine.gpsl.android.util.ToastHelper;
import com.google.gson.reflect.TypeToken;
import com.lidroid.xutils.http.RequestParams;

/**
 * @Title: FeedBackDaoImpl
 * @Package com.anosine.gpsl.android.impl
 * @Description: 接口实现
 * @author: sunny
 * @date: 2015-12-1
 * @version V1.0
 */
public class FeedBackDaoImpl implements FeedBackDao{
	private OnLoadListener loadListener;

	/**
	 * @Title: FeedBackDaoImpl(OnLoadListener loadListener)
	 * @Description: 构造方法，初始化对象，给loadListener赋值
	 * @param: loadListener
	 * @throws
	 */

	public FeedBackDaoImpl(OnLoadListener loadListener) {
		super();
		this.loadListener = loadListener;
	}

	/**
	 * @Title: getFeedBack(String usermd5,String feedbacktitle,String feedbackcontent)
	 * @Description: 调用意见反馈接口
	 * @param usermd5 登录验证串
	 * @param feedbacktitle 意见反馈标题
	 * @param feedbackcontent 意见反馈内容
	 * @return: 无
	 * @throws
	 */

	@Override
	public void getFeedBack(String usermd5,String feedbacktitle,String feedbackcontent) {
		RequestParams params = new RequestParams();
		params.addBodyParameter("usermd5", usermd5);	
		//params.addBodyParameter("feedbacktitle", feedbacktitle);	
		params.addBodyParameter("feedbackcontent", feedbackcontent);		
		SendHttpUtils sendHttp = new SendHttpUtils();
		TypeToken type = new TypeToken<ModifyPwdInfo>() {
		};
		String url = String.format("%1s/%2s", AppConstants.sCommonUrl,
				WebConstants.Do_SubmitFeedBack_Action);
		sendHttp.doRequest(url, params, type,
		/**
		 * @Title: onSuccess(String result, ModifyPwdInfo t)
		 * @Description: 解析成功做的操作
		 * @param: result json
		 * @param: t
		 * @return: 无
		 * @throws
		 */
		new HttpRequestListener<ModifyPwdInfo>() {
			@Override
			public void onSuccess(String result, ModifyPwdInfo t) {

				loadListener.onSuccess(t);

			}

			/**
			 * @Title: onFailure(String error)
			 * @Description: 解析失败做的操作
			 * @param: error 错误信息
			 * @return: 无
			 * @throws
			 */
			@Override
			public void onFailure(String error) {
				loadListener.onFailure();
				ToastHelper.toast(error);
			}
		});

	}

}
